﻿<cfcomponent 
	displayname="public.service.helper.tagFile" 
	hint="CFFile Tag Operation Helper" 
	output="false">
	
	<cffunction name="init" access="public" returntype="public.service.helper.tagFile" hint="初始化对象">
		<cfreturn this />
	</cffunction>
	
	<cffunction name="readBinary" access="public" returntype="any" hint="读取二进制文件">
		<cfargument name="file" type="string" required="yes" hint="目标文件的物理路径" />
		<cffile action="readbinary" file="#arguments.file#" variable="binaryObject" />

		<cfreturn binaryObject />
	</cffunction>
	
	<cffunction name="upload" access="public" returntype="any" hint="上传文件">
		<cfargument name="fileField" type="string" required="yes" hint="上传文件的表单名" />
		<cfargument name="destination" type="string" required="yes" hint="目标文件的物理路径" />
		<cfargument name="accept" type="string" required="yes" hint="允许文件类型 默认为任何类型" />
		
		<cffile action="upload" fileField="#arguments.fileField#" destination="#arguments.destination#" accept="#arguments.accept#" nameconflict="overwrite">
		
		<cfreturn cffile />
	</cffunction>

	<cffunction name="copy" access="public" returntype="void" hint="复制文件">
		<cfargument name="source" type="string" required="yes" hint="来源文件的物理路径" />
		<cfargument name="destination" type="string" required="yes" hint="目标文件的物理路径" />
		
		<cffile action="copy" source="#arguments.source#" destination="#arguments.destination#">

	</cffunction>

	<cffunction name="move" access="public" returntype="void" hint="移动文件">
		<cfargument name="source" type="string" required="yes" hint="来源文件的物理路径" />
		<cfargument name="destination" type="string" required="yes" hint="目标文件的物理路径" />
		
		<cffile action="move" source="#arguments.source#" destination="#arguments.destination#">

	</cffunction>
	
	<cffunction name="delete" access="public" returntype="void" hint="删除文件">
		<cfargument name="file" type="string" required="yes" hint="目标文件的物理路径" />
		
		<cffile action="delete" file="#arguments.file#" />
	
	</cffunction>

</cfcomponent>